# Copyright (c) 2019 Presto Labs Pte. Ltd.
# Author: leon

from coin.exchange.base.kr_rest.currency import NativeCurrency
from coin.exchange.gopax.kr_rest.constants import currency_list


def to_native_currency(currency_str):
  if currency_str == 'BCHABC':
    native_currency_str = 'BCH'
  else:
    native_currency_str = currency_str
  assert native_currency_str in currency_list, native_currency_str
  return native_currency_str


def from_native_currency(native_currency_str):
  assert native_currency_str in currency_list, native_currency_str
  if native_currency_str == 'BCH':
    currency_str = 'BCHABC'
  else:
    currency_str = native_currency_str
  return currency_str


class GopaxCurrency(NativeCurrency):
  _exchange = "Gopax"

  @classmethod
  def FromStrCurrencyImpl(cls, currency_str, current_datetime):
    return cls(currency_str, to_native_currency(currency_str))

  @classmethod
  def FromStrNativeCurrencyImpl(cls, native_currency_str, current_datetime):
    return cls(from_native_currency(native_currency_str), native_currency_str)
